﻿using System;

namespace CollegeSim.Domain.Entities
{
    // Author: Ryan Redburn
    // Project: CollegeSim
    // Date: 2/4/2014

    #region [ Updates ]

    // Author: Ryan Redburn
    // Date: 5/6/2014
    // Revisions: Changed Student to reflect 2.0 changes

    // Author: Ryan Redburn
    // Date: 5/13/2014
    // Revisions: Added student Code to the ToString() method.

    // Author: Ryan Redburn
    // Date: 5/13/2014
    // Revisions: Added additional validation to Code.

    #endregion

    /// <summary>
    /// Class used to represent a Student. Contains properies, ToString() override.
    /// </summary>
    public class Student : Person
    {
        #region [ Fields ]

        private string _code;
        private DateTime _enrollmentDate;

        #endregion

        #region [ Properties ]

        // StudentID
        // Set by DB
        public int StudentID { get; set; }

        /// <summary>
        /// 7-10 character student code.
        /// </summary>
        public string Code
        {
            get { return _code; }
            set
            {
                if (!String.IsNullOrWhiteSpace(value))
                {
                    if (value.Length <= 10 && value.Length >= 7)
                    {
                        _code = value.ToLower();
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("value", "Code must be between(including) seven and ten characters.");
                    }
                }
                else
                {
                    throw new ArgumentNullException("value", "Code cannot be null or empty.");
                }
            }
        }

        /// <summary>
        /// Date of student enrollment.
        /// </summary>
        public DateTime EnrollmentDate
        {
            get { return _enrollmentDate; }
            set { _enrollmentDate = value; }
        }

        #endregion

        #region [ Constructors ]

        // Initialize StudentID
        public Student()
        {
            StudentID = 0;
            PersonID = 0;
        }

        #endregion

        #region [ Methods ]

        /// <summary>
        /// Returns a string representation of a Student. Code - LastName, FirstName - PhoneNumber
        /// </summary>
        /// <returns>Code - LastName, FirstName - PhoneNumber</returns>
        public override string ToString()
        {
            return Code + " - " + LastName + ", " + FirstName + " - " + PhoneNumber;
        }

        #endregion
    }
}
